<template>
  <!-- <keep-alive>  :key="$route.fullPath"-->
  <vab-app />
  <!-- </keep-alive> -->
</template>
<script lang="ts" setup>
  import { onMounted, ref } from 'vue'
  import { useUserStore } from '@/store/modules/user'
  const userStore = useUserStore()
  const { logout } = userStore
  const beforeUnloadTime = ref(0)
  const gapTime = ref(0)

  const beforeunloadHandler = () => {
    beforeUnloadTime.value = new Date().getTime()
  }

  const unloadHandler = () => {
    gapTime.value = new Date().getTime() - beforeUnloadTime.value
    //判断是窗口关闭还是刷新
    if (gapTime.value <= 5) {
      //浏览器关闭

      localStorage.clear()
      sessionStorage.clear()
      logout()
    }
  }

  onMounted(() => {
    //监听页面卸载（关闭）或刷新
    window.addEventListener('beforeunload', () => beforeunloadHandler())

    window.addEventListener('unload', () => unloadHandler())
  })
</script>
<style>
  .el-scrollbar__thumb {
    background-color: #1890ff !important;
  }

  /* .is-horizontal {
  display: block !important;
} */
</style>
